
% Objective-C Foundation Reference Card (part 4)
% Copyright (c) 2003-2008 Dick van Oudheusden
% TeX Format

% Uncomment the following line for dvi/ps generation: tex ofc-refcard4.tex; dvips -o ofc-refcard4.ps ofc-refcard4.dvi
%\input outopt.tex

% Uncomment the following three lines for PDF generation: pdftex ofc-refcard4.tex
\pdfoutput=1
\pdfpageheight=21cm
\pdfpagewidth=29.7cm

% Font definitions
\font\bigbf=cmb12
\font\smallbf=cmb10
\font\smallrm=cmr8
\font\smalltt=cmtt8
\font\smallit=cmmi8
\font\tinyit=cmmi5

\def\cm#1#2{{\smalltt#1}\dotfill{\smallrm#2}\par}
\def\cn#1{\hfill{\smallrm$\lfloor$ #1}\par}
\def\cl#1#2{\hskip 12pt$\lfloor${\smalltt#1}\dotfill{\smallrm#2}\par}
\def\sect#1{\vskip 0.7cm \hfil{\smallbf#1}\hfil\par}
\def\para#1{{\smallit#1}\par}
\def\note#1{{$\smallrm$Note: #1}\par}
\def\vsep{\vskip 6pt}

% Characters definitions
\def\bs{$\backslash$}
\def\backspace{$\leftarrow$}
\def\ctrl{{\rm\char94}\kern-1pt}
\def\enter{$\hookleftarrow$}
\def\or{\thinspace{\tinyit{or}}\thinspace}
\def\key#1{$\langle${\rm{\it#1}}$\rangle$}
\def\rapos{\char125}
\def\lapos{\char123}
\def\bs{\char92}
\def\tild{\char126}

% Three columns definitions
\parindent 0pt
%\nopagenumbers
\hoffset=-1.56cm
\voffset=-1.54cm
\newdimen\fullhsize
\fullhsize=27.9cm
\hsize=8.5cm
\vsize=19cm
\def\fullline{\hbox to\fullhsize}
\let\lr=L
\newbox\leftcolumn
\newbox\midcolumn
\output={
  \if L\lr
    \global\setbox\leftcolumn=\columnbox
    \global\let\lr=M
  \else\if M\lr
    \global\setbox\midcolumn=\columnbox
    \global\let\lr=R
  \else
    \tripleformat
    \global\let\lr=L
  \fi\fi
  \ifnum\outputpenalty>-20000
  \else
    \dosupereject
  \fi}
\def\tripleformat{
  \shipout\vbox{\fullline{\box\leftcolumn\hfil\box\midcolumn\hfil\columnbox}}
  \advancepageno}
\def\columnbox{\leftline{\pagebody}}

% Card content
% Header
%\hrule\vskip 3pt
\hfil{\bf OBJECTIVE-C FOUNDATION CLASSES}\hfil\par
\hfil{\bf REFERENCE CARD}\hfil\par
\hfil{\bf Part 4: Network}\hfil\par
\vskip 2pt\hrule

\sect{FTPClient}
\para{Constants}
\cm{DFPC\_PORT}{Default FTP port}
\cm{DFPC\_PASSIVE}{Passive FTP mode}
\cm{DFPC\_ACTIVE}{Active FTP mode}
\para{Methods}
\cm{- init}{Initialise a FTP client}
\cm{- free}{Free the client}
\cm{- (DSocket *) socket}{Return socket of client}
\cm{- (BOOL) isConnected}{Check if client is connected}
\cm{- (BOOL) mode}{Return FTP client mode}
\cm{- passive}{Set FTP client in passive mode}
\cm{- active :(int) port}{Set FTP client in active mode}
\cm{- (int) responseCode}{Return the last response code}
\cm{- (const char *) directory}{Return the last directory}
\cm{- (int) bytes}{Return the last number of bytes}
\cm{- bufferSize :(int) size}{Set the receive buffer size}
\cm{- (int) bufferSize}{Get the receive buffer size}
\cm{- (BOOL) open :(server}{Open a connection to the server}
\cm{- (BOOL) close}{Close the connnection with the server}
\cm{- (BOOL) sendCommand :(char *) command}{}
\cl{:(char *) parameters}{Send FTP command to the server}
\cm{- (int) receiveResponse}{Receive a response from the server}
\cm{- (BOOL) login :(char *) user :(char *) password}{}
\cl{:(char *) account}{Send a login to the server}
\cm{- (BOOL) transferASCII}{Send the ASCII mode to the server}
\cm{- (BOOL) transferBinary}{Send the binary mode to the server}
\cm{- (BOOL) changeCurrentDirectory :(char *) directory}{}
\cn{Change the current directory on the server}
\cm{- (BOOL) changeCurrentToParent}{}
\cn{Change to parent directory on the server}
\cm{- (BOOL) mount :(char *) directory}{}
\cn{Mount the directory on the server}
\cm{- (BOOL) reinitialize}{Reinitialise the connection to the server}
\cm{- (BOOL) storeASCII :(char *) command :(char *) filename}{}
\cl{:(id) file}{Store ASCII data on the server}
\cm{- (BOOL) overwriteASCII :(char *) filename :(id) file}{}
\cn{Overwrite an ASCII file on the server}
\cm{- (BOOL) appendASCII :(char *) filename :(id>) file}{}
\cn{Append an ASCII file on the server}
\cm{- (BOOL) storeASCIIUnique :(id) file}{}
\cn{Store an ASCII file unique on the server}
\cm{- (BOOL) storeBinary :(char *) command}{}
\cl{:(char *) filename :(id) file}{}
\cn{Store binary data on the server}
\cm{- (BOOL) overwriteBinary :(char *) filename :(id) file}{}
\cn{Overwrita an Binary file on the server}
\cm{- (BOOL) appendBinary :(char *) filename :(id) file}{}
\cn{Append an binary file on the server}
\cm{- (BOOL) storeBinaryUnique :(id) file}{}
\cn{Store an binary file unique on the server}
\cm{- (BOOL) retrieveASCII :(char *) filename :(id) file}{}
\cn{Retrieve an ASCII file from the server}
\cm{- (BOOL) retrieveBinary :(char *) filename :(id) file}{}
\cn{Retrieve an binary file from the server}
\cm{- (BOOL) rename :(char *) oldName :(char *) newName}{}
\cn{Rename a file on the server}
\cm{- (BOOL) delete :(char *) filename}{Delete a file on the server}
\cm{- (BOOL) removeDirectory :(char *) directory}{}
\cn{Remove a directory on the server}
\cm{- (BOOL) makeDirectory :(char *) directory}{}
\cn{Make a directory on the server}
\cm{- (BOOL) getWorkingDirectory}{}
\cn{Get the current working directory on the server}
\cm{- (BOOL) sendListCommand :(char *) command}{}
\cl{:(char *) parameter :(DList *) list}{}
\cn{Send a list commando to the server}
\cm{- (BOOL) list :(char *) name :(DList *) list}{}
\cn{Send a list commando to the server}
\cm{- (BOOL) siteParameter :(char *) parameter}{}
\cn{Send a site parameters commando to the server}
\cm{- (BOOL) systemInfo}{Send system info request to the server}
\cm{- (BOOL) state}{Send status info request to the server}
\cm{- (BOOL) help :(char *) key}{Send help info request to the server}
\cm{- (BOOL) noop}{Send No Operation request to the server}
\cm{- (BOOL) nameList :(char *) directory :(DList *) list}{}
\cn{Send a named list request to the server}
\cm{- (BOOL) quit}{Send a logout request to the server}
\cm{- (DText *) getASCIIData}{Callback during ASCII store}
\cm{- (DData *) getBinaryData :(int) bufferSize}{}
\cn{Callback during binary store}
\cm{- (void) setASCIIData :(char *) cstring}{}
\cn{Callback during ASCII retrieve}
\cm{- (void) setBinaryData :(uchar *) data :(ulong) length}{}
\cn{Callback during binary retrieve}
\cm{- (void) processResponse :(int) code :(char *) response}{}
\cn{Callback for received responses}
\cm{- (void) processListLine :(char *) line}{}
\cn{Callback for received (named) list info}


\sect{DHTTPClient}
\para{Constants}
\cm{DHTTP\_PORT}{Default HTTP port}
\cm{DHC\_HEAD}{HTTP Head request}
\cm{DHC\_GET}{HTTP Get request}
\para{Methods}
\cm{- init}{Initialise a HTTP client (def. version: 1.1)}
\cm{- init :(int) major :(int) minor}{Init client with version}
\cm{- free}{Free the HTTP client}
\cm{- (DSocket *) socket}{Return the socket of the client}
\cm{- (BOOL) sendStartRequest :(int) request :(DURL *) path}{}
\cn{Send a HTTP request to the server in the URL}
\cm{- (BOOL) sendStartRequest :(int) request :(DURL *) path}{}
\cl{:(char *) proxy :(int) proxyPort}{Send request via proxy}
\cm{- (BOOL) sendHeader :(char *) header :(char *) argument}{}
\cn{Send a header after the HTTP request}
\cm{- (BOOL) sendAcceptLanguageHeader :(char *) languages}{}
\cn{Send accept-language header}
\cm{- (BOOL) sendUserAgentHeader :(char *) agent}{}
\cn{Send user accept header}
\cm{- (BOOL) sendRefererHeader :(char *) referer}{}
\cn{Send referer header}
\cm{- (BOOL) sendConnectionHeader :(char *) connection}{}
\cn{Send the nextconnection state: close or keep-alive}
\cm{- (BOOL) sendEndRequest}{Send the end of the request}
\cm{- (BOOL) receiveReply}{Receive a reply after a request}
\cm{- (int) reason}{Get the reason in the reply}
\cm{- (char *) reasonText}{Get the reason text in the reply}
\cm{- (int) peerMajor}{Return the major version of peer}
\cm{- (int) peerMinor}{Return the minor version of peer}
\cm{- (DText *) header :(char *) header}{}
\cn{Get the argument of header in the reply}
\cm{- (DHashIterator *) headers}{Get all headers in the reply}
\cm{- (const unsigned char *) body}{Get the data in the body}
\cm{- (unsigned long) bodyLength}{Get the length of the body}

\sect{DTCPServer}
\para{Constants}
\cm{DTS\_BLOCKING}{Connections are blocking}
\cm{DTS\_THREADING}{Connections in a thread}
\cm{DTS\_FORKING}{Connections in a child process}
\para{Methods}
\cm{- init}{Init default tcp server}
\cm{- init :(int) family :(int) prot}{Init and open tcp server}
\cm{- free}{Free tcp server}
\cm{- (DSocket *) socket}{Return socket of server}
\cm{- sendFlag :(int) flag}{Set the send flag}
\cm{- (int) sendFlag}{Return the send flag}
\cm{- recvFlag :(int) flag}{Set the receive flag}
\cm{- (int) recvFlag}{Return the receive flag}
\cm{- recvLength :(unsigned) length}{Set the receive length}
\cm{- (unsigned) recvLength}{Return the receive length}
\cm{- (BOOL) open :(int) family :(int) prot}{Open tcp server}
\cm{- (BOOL) start :(int) addr :(int) backlog :(int) mode}{}
\cl{:(int) connections}{Start server, wait for connections}
\cm{- handleConnection :(DSocket *) peer}{Handle new connection}
\cm{- (BOOL) handleRequest :(DData *) request}{}
\cl{:(DData *) response}{Handle request from client}

\sect{DTCPClient}
\para{Methods}
\cm{- init}{Init default tcp client}
\cm{- init :(int) family :(int) protocol}{Init tcp client}
\cm{- free}{Free tcp client}
\cm{- (DSocket *) socket}{Return socket of client}
\cm{- (BOOL) isConnected}{Test for open connection}
\cm{- sendFlag :(int) flag}{Set send flag}
\cm{- (int) sendFlag}{Return send flag}
\cm{-  recvFlag :(int) flag}{Set the receive flag}
\cm{- (int) recvFlag}{Return the receive flag}
\cm{- (BOOL) open :(int) family :(int) prot}{Open tcp client}
\cm{- (BOOL) start :(id) address}{Start connection with server}
\cm{- (DData *) doRequest :(uchar *) request :(unsigned) len}{}
\cl{:(unsigned) respLen}{Send request and wait for response}
\cm{- stop}{Stop connection}

\sect{DTelNetClient}
\para{Constants}
\cm{DTNC\_PORT}{Default Telnet port}
\cm{DTNC\_IAC}{Command: Interpret as command}
\cm{DTNC\_DONT}{Command: Do not use this option}
\cm{DTNC\_DO}{Command:  Do use this option}
\cm{DTNC\_WONT}{Command: Will not use this option}
\cm{DTNC\_WILL}{Command: Will use this option}
\cm{DTNC\_SB}{Command:  Start subnegotiation}
\cm{DTNC\_GA}{Command:  Go ahead}
\cm{DTNC\_EL}{Command:  Erase line}
\cm{DTNC\_EC}{Command:  Erase character}
\cm{DTNC\_AYT}{Command: Are you there}
\cm{DTNC\_AO}{Command:  Abort output}
\cm{DTNC\_IP}{Command:  Interrupt process}
\cm{DTNC\_BRK}{Command: Break}
\cm{DTNC\_DM}{Command:  Data mark}
\cm{DTNC\_NOP}{Command: No operation}
\cm{DTNC\_SE}{Command:  End subnegotiation}
\cm{DTNC\_BINARY}{Option: 8-bit data path}
\cm{DTNC\_ECHO}{Option: Echo}
\cm{DTNC\_RCP}{Option: Prepare to reconnect}
\cm{DTNC\_SGA}{Option: Suppress go ahead}
\cm{DTNC\_NAMS}{Option: Approximate message size}
\cm{DTNC\_STATUS}{Option: Give status}
\cm{DTNC\_TM}{Option: Timing mark}
\cm{DTNC\_RCTE}{Option:Remote controlled transmission and echo}
\cm{DTNC\_NAOL}{Option: Output line width}
\cm{DTNC\_NAOP}{Option: Output page size}
\cm{DTNC\_NAOCRD}{Option: CR disposition}
\cm{DTNC\_NAOHTS}{Option: Horizontal tabstops}
\cm{DTNC\_NAOHTD}{Option: Horizontal tab disposition}
\cm{DTNC\_NAOFFD}{Option: Formfeed disposition}
\cm{DTNC\_NAOVTS}{Option: Vertical tab stops}
\cm{DTNC\_NAOVTD}{Option: Vertical tab disposition}
\cm{DTNC\_NAOLFD}{Option: LF disposition}
\cm{DTNC\_XASCII}{Option: Extended ascii character set}
\cm{DTNC\_LOGOUT}{Option: Force logout}
\cm{DTNC\_BM}{Option: Byte macro}
\cm{DTNC\_DET}{Option: Data entry terminal}
\cm{DTNC\_SUPDUP}{Option: Supdup protocol}
\cm{DTNC\_SUPDUPOUTPUT}{Option: Supdup output}
\cm{DTNC\_SNDLOC}{Option: Send location}
\cm{DTNC\_TTYPE}{Option: Terminal type}
\cm{DTNC\_EOR}{Option: End or record}
\cm{DTNC\_TUID}{Option: TACACS user identification}
\cm{DTNC\_OUTMRK}{Option: Output marking}
\cm{DTNC\_TTYLOC}{Option: Terminal location number}
\cm{DTNC\_3270REGIME}{Option: 3270 regime}
\cm{DTNC\_X3PAD}{Option: X.3 PAD}
\cm{DTNC\_NAWS}{Option: Window size}
\cm{DTNC\_TSPEED}{Option: Terminal speed}
\cm{DTNC\_LFLOW}{Option: Remote flow control}
\cm{DTNC\_LINEMODE}{Option: Linemode option}
\cm{DTNC\_XDISPLOC}{Option: X Display Location}
\cm{DTNC\_OLD\_ENVIRON}{Option: Old - Environment variables}
\cm{DTNC\_AUTHENTICATION}{Option: Authenticate}
\cm{DTNC\_ENCRYPT}{Option: Encryption option}
\cm{DTNC\_NEW\_ENVIRON}{Option: Environment variables}
\cm{DTNC\_SERVER}{Who: server}
\cm{DTNC\_CLIENT}{Who: client}
\para{Class Methods}
\cm{+ (char *) commandToString :(uchar) command}{}
\cn{Convert command to a string}
\cm{+ (char *) optionToString :(int) option}{}
\cn{Convert an option to a string}
\para{Object Methods}
\cm{- init}{Init a telnet client}
\cm{- free}{Free the telnet client}
\cm{- (DSocket *) socket}{Return the socket of the client}
\cm{- (BOOL) isConnected}{Check for connection with server}
\cm{- (BOOL) option :(int) who :(int) option}{}
\cn{Check state of option}
\cm{- (BOOL) open :(id) server}{Open connection to server}
\cm{- (BOOL) close}{Close connection to server}
\cm{- (BOOL) requestOpenNegotiation :(int) who :(int) option}{}
\cl{:(BOOL) state}{Put open negotiation request in send buffer}
\cm{- (BOOL) requestSubNegotiation :(int) option}{}
\cn{Put sub negotiation request in send buffer}
\cm{- (BOOL) respondSubNegotiation :(int) option}{}
\cl{:(char *) data :(int) length}{}
\cn{Put sub negotiation response in send buffer}
\cm{- (BOOL) respondNegotiation :(int) who :(int) option}{}
\cl{:(BOOL) accepted}{Put negotiation response in send buffer}
\cm{- (BOOL) AYT}{Put Are You There in send buffer}
\cm{- (BOOL) sendText :(const unsigned char *) text}{}
\cn{Put normal text in send buffer en send buffer to server}
\cm{- (BOOL) pendingRequests}{}
\cn{Check for pending messages in send buffer}
\cm{- (BOOL) pendingNegotiations}{Check for pending negotiations}
\cm{- (DData *) receive }{Receive data from server}
\cm{- (BOOL) receive :(DData *) response}{}
\cn{Receive data from server}
\cm{- (BOOL) processSpecialCommand :(unsigned char) command}{}
\cn{Process commands received from server (to be overridden)}
\cm{- (BOOL) processOpenNegotiation :(int) who :(int) option}{}
\cl{:(int) state}{Process received open negotiation (override)}
\cm{- (BOOL) processResponseNegotiation :(int) who}{}
\cl{:(BOOL) accepted :(int) option}{}
\cn{Process received negotiation response (to be overridden)}
\cm{- (BOOL) processRequestSubNegotiation :(int) option}{}
\cn{Process received sub negotiation request (to be overridden)}
\cm{- (BOOL) processResponseSubNegotiation :(int) option}{}{}
\cl{:(char *) data :(int) length}{}
\cn{Process received sub negotiation response (to be overridden)}

\sect{DUDPServer}
\para{Methods}
\cm{- init}{Init default udp server}
\cm{- init :(int) family :(int) prot}{Init and open udp server}
\cm{- free}{Free udp server}
\cm{- (DSocket *) socket}{Return socket of server}
\cm{- sendFlag :(int) flag}{Set the send flag}
\cm{- (int) sendFlag}{Return the send flag}
\cm{- recvFlag :(int) flag}{Set the receive flag}
\cm{- (int) recvFlag}{Return the receive flag}
\cm{- recvLength :(unsigned) length}{Set the receive length}
\cm{- (unsigned) recvLength}{Return the receive length}
\cm{- (BOOL) open :(int) family :(int) prot}{Open udp server}
\cm{- (BOOL) start :(id) addr}{Start server, blocking}
\cm{- (BOOL) handleRequest :(DData *) request}{}
\cl{:(DData *) response}{Handle request from client}

\sect{DUDPClient}
\para{Methods}
\cm{- init}{Init default udp client}
\cm{- init :(int) family :(int) protocol}{Init udp client}
\cm{- free}{Free udp client}
\cm{- (DSocket *) socket}{Return socket of client}
\cm{- sendFlag :(int) flag}{Set send flag}
\cm{- (int) sendFlag}{Return send flag}
\cm{-  recvFlag :(int) flag}{Set the receive flag}
\cm{- (int) recvFlag}{Return the receive flag}
\cm{- (BOOL) open :(int) family :(int) prot}{Open udp client}
\cm{- (BOOL) start :(id) address}{Start connection}
\cm{- (DData *) doRequest :(id) server :(uchar *) request}{}
\cl{:(unsigned) len :(unsigned) respLen}{}
\cn{Send request and wait for response}
\cm{- stop}{Stop connection}

\sect{DURL}
\para{Methods}
\cm{- init}{Init empty url}
\cm{- init :(char *) url}{Init with url}
\cm{- free}{Free url}
\cm{- shallowCopy}{Copy the url}
\cm{- (char *) scheme}{Return the scheme in the url}
\cm{- (char *) protocol}{Return the protocol in the url}
\cm{- scheme :(char *) scheme}{Set the scheme in the url}
\cm{- (char *) user}{Return the user in the url}
\cm{- user :(char *) user}{Set the user in the url}
\cm{- (char *) password}{Return the password in the url}
\cm{- password :(char *) password}{Set the password}
\cm{- (char *) host}{Return the host in the url}
\cm{- host :(char *) host}{Set the host in the url}
\cm{- (int) port}{Return the port in the url}
\cm{- port :(int) port}{Set the port in the url}
\cm{- (char *) path}{Return the path in the url}
\cm{- path :(char *) path}{Set the path in the url}
\cm{- clear}{Clear the url}
\cm{- (DText *) url}{Return the url}
\cm{- (BOOL) url :(char *) url}{Set the url}
\cm{- (BOOL) url :(char *) url :(DURL *) ref}{}
\cn{Set url with reference url}
\cm{- (int) fromString :(char **) cstr}{}
\cn{Read url from string}
\cm{- (DText *) toText}{Convert url to text string}


% Footer
\vfill \hrule\smallskip
{\smallrm Version 0.7.1. This card may be freely distributed under 
the terms of the GNU general public licence\par
Copyright \copyright\ {\oldstyle 2003-2008} by Dick van Oudheusden}

% Ending
\supereject
\if L\lr \else\null\vfill\eject\fi
\if L\lr \else\null\vfill\eject\fi
\bye

% EOF
